<template>
  <el-dialog
    :title="title"
    :visible.sync="openDlg"
    width="500px"
    append-to-body
    destroy-on-close
  >
    <el-form ref="form" :model="form" :rules="rules" label-width="90px">
      <el-row>
        <el-col :span="24">
          <el-form-item label="审核结果" prop="status">
              <el-radio-group v-model="form.status">
                  <el-radio label="1">通过</el-radio>
                  <el-radio label="2">不通过</el-radio>
              </el-radio-group>
          </el-form-item>
        </el-col>
        <el-col :span="24" v-if="form.status == '2'">
          <el-form-item label="不通过原因" prop="rejectMsg">
              <el-input v-model.trim="form.rejectMsg" placeholder="请输入不通过原因" />
          </el-form-item>
        </el-col>
        
      </el-row>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button type="primary" @click="submitForm">确 定</el-button>
      <el-button @click="openDlg = false">取 消</el-button>
    </div>
  </el-dialog>
</template>

<script>
 import { 
    studentIDApprove
  } from "@/api/dailyroutine/studentID.js";
export default {
  name:"auditDlg",
  props:{
    
  },
  data () {
      return {
          title: '审核',
          openDlg: false,
          // 表单参数
          form: {},
          // 表单校验
          rules: {
              status: [
                { required: true, message: '请选择审核结果', trigger: 'change' }
              ],
              rejectMsg: [
                { required: true, message: '请输入不通过原因', trigger: 'blur' }
              ]
          }
      }
  },
  methods:{
      open (row) {
        this.form = {
          ...row,
          status: '1',
          rejectMsg: ''
        }
        this.openDlg = true
      },
      submitForm () {
        this.$refs["form"].validate((valid) => {
          if (valid) {
            studentIDApprove({
              id: this.form.id,
              status: this.form.status,
              rejectMsg: this.form.rejectMsg
            }).then((response) => {
              this.$modal.msgSuccess("审批完成");
              this.openDlg = false;
              this.$emit("onSearch")
            });
          }
        });
      },
  }
}
</script>

<style lang="scss" scoped>

</style>